package com.dimples.security.captcha;

import cn.hutool.core.date.DateUtil;
import lombok.Data;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2021/6/18
 */
@Data
public class CaptchaCode {

    private String code;

    private String expireTime;

    public CaptchaCode(String code, int expireIn) {
        this.code = code;
        this.expireTime = DateUtil.formatDateTime(DateUtil.offsetSecond(DateUtil.parseDateTime(DateUtil.now()), expireIn));
    }

    public boolean isExpire() {
        return DateUtil.parseDateTime(DateUtil.now()).after(DateUtil.parseDateTime(expireTime));
    }

}
